﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using DLL;

namespace BLL
{
   public class NguoiDungBLL
    {
       DataServer DB = new DataServer();
       public DataTable Select_ALL()
       {
           string sql = @"SELECT        NhanVien.MaNv, (NhanVien.HoDem +' '+NhanVien.TenNV) as HoTen, NhanVien.MatKhau, Quyen.TenQuyen
                            FROM  NhanVien inner Join Quyen on NhanVien.Quyen=Quyen.MaQuyen";

           DataTable bang = DB.LayDulieu(sql);
           return bang;
       }
     
       public bool Sua(NhanVienDAL nv)
       {
           string sql = "update NhanVien set MatKhau=@MatKhau,Quyen=@Quyen where MaNv=@Manv";
           SqlParameter paramMK= new SqlParameter("@MatKhau",nv.Pass);
           SqlParameter paramQ = new SqlParameter("@Quyen",nv.Quyen);
           SqlParameter paramMNV = new SqlParameter("@Manv", nv.MaNv);
           //try
           //{
               DB.CapNhat(sql, paramMK,paramQ,paramMNV);
           //}
           //catch
           //{
           //    return false;
           //}
           return true;
       }
    }
}
